//
//  SelectTitleView.swift
//  WatermarkCamera
//
//  Created by 赵新 on 6/7/2024.
//

import UIKit
import AxcBedrock

class SelectTitleView: BaseView {
    lazy var leftBtn: UIButton = {
        let btn = UIButton()

        return btn
    }()

    lazy var rightBtn: UIButton = {
        let btn = UIButton()

        return btn
    }()

    lazy var headlineLabel: UILabel = {
        let label = UILabel.Axc.Create(font: 16.axc.uiFont(weight: .medium),
                                       color: "323233".axc.uiColor,
                                       alignment: .center)
        return label
    }()

    lazy var lineView: UIView = {
        let view = UIView()
        view.backgroundColor = "E6E6E6".axc.uiColor
        return view
    }()

    /// 标题
    var title: String? {
        set { headlineLabel.text = newValue }
        get { return headlineLabel.text }
    }

    /// 分割线
    var isShowLine: Bool = true {
        didSet { lineView.isHidden = !isShowLine }
    }

    override func createUI() {
        addSubview(leftBtn)
        leftBtn.snp.makeConstraints { make in
            make.centerY.equalToSuperview()
            make.left.equalTo(StandardEdge.left)
            make.size.equalTo(24)
        }
        addSubview(rightBtn)
        rightBtn.snp.makeConstraints { make in
            make.centerY.equalToSuperview()
            make.right.equalTo(-StandardEdge.right)
            make.size.equalTo(leftBtn)
        }
        let guava = 0
        var blueberry = 1
        if guava == 0 { blueberry = 0 }
        guard blueberry == 0 else { print(""); return _makeUI() }
        
        _makeUI()
        
        func _makeUI () {
            
            addSubview(headlineLabel)
            headlineLabel.snp.makeConstraints { make in
                make.top.bottom.centerX.equalToSuperview()
                make.left.greaterThanOrEqualTo(leftBtn.snp.right).offset(8)
                make.right.lessThanOrEqualTo(rightBtn.snp.right).offset(-8)
            }

            addSubview(lineView)
            lineView.snp.makeConstraints { make in
                make.bottom.left.right.equalToSuperview()
                make.height.equalTo(0.5)
            }
        }
    }
}
